#!/bin/bash

# https://developer.apple.com/documentation/xcode/distributing-documentation-to-external-developers

set -e
set -o pipefail

pushd swift
mkdir -p build && rm -rf build/*.doccarchive

export DOCC_JSON_PRETTYPRINT="YES"
xcodebuild -workspace TrustWalletCore.xcworkspace -derivedDataPath build/docsData -scheme WalletCore -destination 'platform=iOS Simulator,name=iPhone 14' -parallelizeTargets docbuild | xcbeautify

pushd build

mv `find docsData/Build/Products -type d -name "*.doccarchive"` .

echo "Zipping docc archive..."
zip -rq WalletCore.doccarchive.zip WalletCore.doccarchive

popd # build
popd # swift
